
<!doctype html>
<html lang="zh-CN">
<head>
    <!-- 必须的 meta 标签 -->
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <!-- Bootstrap 的 CSS 文件 -->
    <link rel="stylesheet" href="bootstrap-4.6.0-dist/css/bootstrap.min.css" />
    <script src="scripts/jquery-3.6.0.min.js"></script>
    <script src="bootstrap-4.6.0-dist/js/bootstrap.bundle.min.js"></script>
    <title>快速角色启动</title>
</head>

<body>
    <ul class="nav nav-tabs">
        <li class="nav-item">
            <a href="dashboard" class="nav-link">仪表板</a>
        </li>
        <li class="nav-item">
            <a href="quikly" class="nav-link active">快速启动</a>
        </li>
        <li class="nav-item">
            <a href="cgasettings" class="nav-link">CGA软件设置</a>
        </li>
        <!--<li class="nav-item">
            <a href="accounts" class="nav-link">账号管理</a>
        </li>
        <li class="nav-item">
            <a href="characters" class="nav-link">游戏角色管理</a>
        </li>-->
    </ul>
    <div class="tab-content">
        <div class="tab-pane fade show active" id="quikly" role="tabpanel">
<div class="container-fluid">
    <h3 style="margin-top: 8px;">可启动角色列表</h3>
    <table class="">
        <tr>
            <td style="padding: 4px;" class="form-inline">
                <span>选择服务器：</span>
                <select class="custom-control custom-select" onchange="onChangeServer(this.value);">
                    <option value="4" selected>道具电信</option>
                    <option value="40">道具网通</option>
                </select>
            </td>
            <td style="padding: 4px;"><a class="btn btn-link" href="addchara">添加角色</a></td>
            <td style="padding: 4px;" class="form-inline">
                <span>批量操作：</span>
                <select class="custom-control custom-select">
                    <option value="onBtnSave">保存</option>
                    <option value="onBtnStartup">启动</option>
                </select>&nbsp;
                <input type="button" class="btn btn-warning" value="执行" onclick="onMultiExec( $(this).prev().val() );" />
            </td>
        </tr>
    </table>

    <script>
        // 脚本和设置文件
        var scriptFiles = [ "flandre.js", "mytest.js", "【功能】穿某些NPC.js", "【功能】自动遇敌.js", "【功能】艾尔莎岛走到银行打开银行对话框.js", "【功能】说话防掉线.js", "【功能】鉴定全部物品.js", "【测试】自动加载玩家设置.js", "【狩猎】0秒挖鹿皮.js", "【练级】Lv1新号东门.js" ];
        var settingsFiles = [ "[物理系]乱射+气功弹II.json", "[物理系]人低级气功弹+宠普攻带吸血.json", "[物理系]人低级气功弹带低级单补自己+宠普攻带吸血.json", "[物理系]人气功弹带单补自己+宠弹II普攻带吸血.json", "[物理系]格斗士气功弹+宠弹II普攻.json", "[物理系]默认普攻.json", "[生产系]默认普攻.json", "[魔法系]人成长传教+宠普攻带吸血.json", "[魔法系]人高级传教+宠气功弹II.json", "叶兰世家.json", "存在之因.json", "我是小红帽.json", "时臣保护委员会.json" ];
        // 判断是否运行中
        function chara_judge_running(charaId) {
            $.ajax( {
                url: 'action/getchara',
                data: { chara_id: charaId },
                dataType: 'json',
                success: function(chara) {
                    //console.log(chara);
                    if ( chara.cga_port > 0 ) {
                        $.ajax({
                            url: 'action/checkguiport',
                            data: { gui_port: chara.cga_port },
                            dataType: 'json',
                            timeout: 3000,
                            success: function(data) {
                                console.log(data);
                                if (data.error) {
                                    $('#btn-chara'+charaId+'-startup').prop('disabled', false);
                                    $('#btn-chara'+charaId+'-startup').text('启动');
                                    $('#btn-chara'+charaId+'-startup').removeClass('btn-danger');
                                    $('#btn-chara'+charaId+'-startup').addClass('btn-success');
                                    $.ajax( {
                                        url: 'action/quiklysave',
                                        data: { chara_id: charaId, cga_port: 0 },
                                        dataType: 'json',
                                        success: function(data) {
                                            if ( !data.error ) {
                                                var charaname = $('#chara'+charaId+'-chara_name').text();
                                                console.log('清空【'+charaname+'】的端口号');
                                            }
                                        }
                                    } );
                                }
                                else {
                                    
                                }
                            },
                            error: function(x,s,e) {
                                //console.log(s,e);
                                if ( s == 'timeout' ) {
                                    $('#btn-chara'+charaId+'-startup').prop('disabled', false);
                                    $('#btn-chara'+charaId+'-startup').text('启动');
                                    $('#btn-chara'+charaId+'-startup').removeClass('btn-danger');
                                    $('#btn-chara'+charaId+'-startup').addClass('btn-success');
                                    $.ajax( {
                                        url: 'action/quiklysave',
                                        data: { chara_id: charaId, cga_port: 0 },
                                        dataType: 'json',
                                        success: function(data) {
                                            if ( !data.error ) {
                                                var charaname = $('#chara'+charaId+'-chara_name').text();
                                                console.log('清空【'+charaname+'】的端口号');
                                            }
                                        }
                                    } );
                                }
                                else {
                                }
                            },
                        });
                    }
                }
            } );
            
        }
    </script>

    <table class="table table-hover table-sm">
    <thead>
    <tr>
      <th scope="col">
          <div class="custom-control custom-checkbox">
            <input type="checkbox" class="custom-control-input" onclick="$('.chara-selected-checkbox').prop('checked', this.checked); $('.chara-selected').prop('disabled', !this.checked);" id="chk-all_select" />
            <label class="custom-control-label" for="chk-all_select">全选</label>
          </div>

      </th>
      <th scope="col">角色</th>
      <th scope="col">左右</th>
      <th scope="col">线路</th>
      <th scope="col">自动登录</th>
      <th scope="col">跳过更新</th>
      <th scope="col">自动换线</th>
      <th scope="col">脚本自动重启</th>
      <th scope="col">受伤保护</th>
      <th scope="col">掉魂保护</th>
      <th scope="col">加载脚本</th>
      <th scope="col">加载设置</th>
      <th scope="col">操作</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td>
            <input type="hidden" class="form-control form-control-sm chara-selected" id="chara3-selected" value="3" disabled />
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input chara-selected-checkbox" onchange="document.getElementById('chara3-selected').disabled = !this.checked;" id="chk-chara3-selected" />
                <label class="custom-control-label" for="chk-chara3-selected"></label>
            </div>
        </td>
        <td>
            <span id="chara3-chara_name">存在之因</span>
            <input type="hidden" id="chara3-gid_name" value="zthitemmoli" />
            <input type="hidden" id="chara3-server_id" value="4" />
            <input type="hidden" id="chara3-account_name" value="zthitemmoli" />
        </td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara3-chara_lr">
            <option value="1" selected>左</option>
            <option value="2">右</option>
        </select></td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara3-server_line">
            <option value="1">1线</option>
            <option value="2">2线</option>
            <option value="3">3线</option>
            <option value="4" selected>4线</option>
            <option value="5">5线</option>
            <option value="6">6线</option>
            <option value="7">7线</option>
            <option value="8">8线</option>
            <option value="9">9线</option>
            <option value="10">10线</option>
        </select></td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara3-autologin" checked />
                <label class="custom-control-label" for="chara3-autologin"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara3-skipupdate" checked />
                <label class="custom-control-label" for="chara3-skipupdate"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara3-autochangeserver" />
                <label class="custom-control-label" for="chara3-autochangeserver"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara3-scriptautorestart" checked />
                <label class="custom-control-label" for="chara3-scriptautorestart"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara3-injuryprotect" />
                <label class="custom-control-label" for="chara3-injuryprotect"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara3-soulprotect" />
                <label class="custom-control-label" for="chara3-soulprotect"></label>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-script_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara3-loadscript" value="【功能】说话防掉线.js" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    scriptFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-settings_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara3-loadsettings" value="[物理系]人低级气功弹带低级单补自己+宠普攻带吸血.json" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    settingsFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <button class="btn btn-info btn-sm" id="btn-chara3-save" onclick="onBtnSave(3);">保存</button>
            <button class="btn btn-success btn-sm" id="btn-chara3-startup" onclick="onBtnStartup(3);">启动</button>
            <script>
                chara_judge_running(3);
            </script>
        </td>
    </tr>
    <tr>
        <td>
            <input type="hidden" class="form-control form-control-sm chara-selected" id="chara4-selected" value="4" disabled />
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input chara-selected-checkbox" onchange="document.getElementById('chara4-selected').disabled = !this.checked;" id="chk-chara4-selected" />
                <label class="custom-control-label" for="chk-chara4-selected"></label>
            </div>
        </td>
        <td>
            <span id="chara4-chara_name">存在之果</span>
            <input type="hidden" id="chara4-gid_name" value="zthitemmoli01" />
            <input type="hidden" id="chara4-server_id" value="4" />
            <input type="hidden" id="chara4-account_name" value="zthitemmoli" />
        </td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara4-chara_lr">
            <option value="1" selected>左</option>
            <option value="2">右</option>
        </select></td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara4-server_line">
            <option value="1">1线</option>
            <option value="2">2线</option>
            <option value="3">3线</option>
            <option value="4" selected>4线</option>
            <option value="5">5线</option>
            <option value="6">6线</option>
            <option value="7">7线</option>
            <option value="8">8线</option>
            <option value="9">9线</option>
            <option value="10">10线</option>
        </select></td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara4-autologin" checked />
                <label class="custom-control-label" for="chara4-autologin"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara4-skipupdate" checked />
                <label class="custom-control-label" for="chara4-skipupdate"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara4-autochangeserver" />
                <label class="custom-control-label" for="chara4-autochangeserver"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara4-scriptautorestart" checked />
                <label class="custom-control-label" for="chara4-scriptautorestart"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara4-injuryprotect" />
                <label class="custom-control-label" for="chara4-injuryprotect"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara4-soulprotect" />
                <label class="custom-control-label" for="chara4-soulprotect"></label>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-script_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara4-loadscript" value="【功能】说话防掉线.js" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    scriptFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-settings_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara4-loadsettings" value="[物理系]人低级气功弹带低级单补自己+宠普攻带吸血.json" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    settingsFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <button class="btn btn-info btn-sm" id="btn-chara4-save" onclick="onBtnSave(4);">保存</button>
            <button class="btn btn-success btn-sm" id="btn-chara4-startup" onclick="onBtnStartup(4);">启动</button>
            <script>
                chara_judge_running(4);
            </script>
        </td>
    </tr>
    <tr>
        <td>
            <input type="hidden" class="form-control form-control-sm chara-selected" id="chara5-selected" value="5" disabled />
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input chara-selected-checkbox" onchange="document.getElementById('chara5-selected').disabled = !this.checked;" id="chk-chara5-selected" />
                <label class="custom-control-label" for="chk-chara5-selected"></label>
            </div>
        </td>
        <td>
            <span id="chara5-chara_name">存在之法</span>
            <input type="hidden" id="chara5-gid_name" value="zthitemmoli02" />
            <input type="hidden" id="chara5-server_id" value="4" />
            <input type="hidden" id="chara5-account_name" value="zthitemmoli" />
        </td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara5-chara_lr">
            <option value="1" selected>左</option>
            <option value="2">右</option>
        </select></td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara5-server_line">
            <option value="1">1线</option>
            <option value="2">2线</option>
            <option value="3">3线</option>
            <option value="4" selected>4线</option>
            <option value="5">5线</option>
            <option value="6">6线</option>
            <option value="7">7线</option>
            <option value="8">8线</option>
            <option value="9">9线</option>
            <option value="10">10线</option>
        </select></td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara5-autologin" checked />
                <label class="custom-control-label" for="chara5-autologin"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara5-skipupdate" checked />
                <label class="custom-control-label" for="chara5-skipupdate"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara5-autochangeserver" />
                <label class="custom-control-label" for="chara5-autochangeserver"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara5-scriptautorestart" checked />
                <label class="custom-control-label" for="chara5-scriptautorestart"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara5-injuryprotect" />
                <label class="custom-control-label" for="chara5-injuryprotect"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara5-soulprotect" />
                <label class="custom-control-label" for="chara5-soulprotect"></label>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-script_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara5-loadscript" value="【功能】说话防掉线.js" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    scriptFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-settings_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara5-loadsettings" value="[魔法系]人成长传教+宠普攻带吸血.json" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    settingsFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <button class="btn btn-info btn-sm" id="btn-chara5-save" onclick="onBtnSave(5);">保存</button>
            <button class="btn btn-success btn-sm" id="btn-chara5-startup" onclick="onBtnStartup(5);">启动</button>
            <script>
                chara_judge_running(5);
            </script>
        </td>
    </tr>
    <tr>
        <td>
            <input type="hidden" class="form-control form-control-sm chara-selected" id="chara6-selected" value="6" disabled />
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input chara-selected-checkbox" onchange="document.getElementById('chara6-selected').disabled = !this.checked;" id="chk-chara6-selected" />
                <label class="custom-control-label" for="chk-chara6-selected"></label>
            </div>
        </td>
        <td>
            <span id="chara6-chara_name">存在之理</span>
            <input type="hidden" id="chara6-gid_name" value="zthitemmoli03" />
            <input type="hidden" id="chara6-server_id" value="4" />
            <input type="hidden" id="chara6-account_name" value="zthitemmoli" />
        </td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara6-chara_lr">
            <option value="1" selected>左</option>
            <option value="2">右</option>
        </select></td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara6-server_line">
            <option value="1">1线</option>
            <option value="2">2线</option>
            <option value="3">3线</option>
            <option value="4" selected>4线</option>
            <option value="5">5线</option>
            <option value="6">6线</option>
            <option value="7">7线</option>
            <option value="8">8线</option>
            <option value="9">9线</option>
            <option value="10">10线</option>
        </select></td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara6-autologin" checked />
                <label class="custom-control-label" for="chara6-autologin"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara6-skipupdate" checked />
                <label class="custom-control-label" for="chara6-skipupdate"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara6-autochangeserver" />
                <label class="custom-control-label" for="chara6-autochangeserver"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara6-scriptautorestart" checked />
                <label class="custom-control-label" for="chara6-scriptautorestart"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara6-injuryprotect" />
                <label class="custom-control-label" for="chara6-injuryprotect"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara6-soulprotect" />
                <label class="custom-control-label" for="chara6-soulprotect"></label>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-script_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara6-loadscript" value="【功能】说话防掉线.js" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    scriptFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-settings_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara6-loadsettings" value="[物理系]人低级气功弹带低级单补自己+宠普攻带吸血.json" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    settingsFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <button class="btn btn-info btn-sm" id="btn-chara6-save" onclick="onBtnSave(6);">保存</button>
            <button class="btn btn-success btn-sm" id="btn-chara6-startup" onclick="onBtnStartup(6);">启动</button>
            <script>
                chara_judge_running(6);
            </script>
        </td>
    </tr>
    <tr>
        <td>
            <input type="hidden" class="form-control form-control-sm chara-selected" id="chara7-selected" value="7" disabled />
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input chara-selected-checkbox" onchange="document.getElementById('chara7-selected').disabled = !this.checked;" id="chk-chara7-selected" />
                <label class="custom-control-label" for="chk-chara7-selected"></label>
            </div>
        </td>
        <td>
            <span id="chara7-chara_name">存在之道</span>
            <input type="hidden" id="chara7-gid_name" value="zthitemmoli04" />
            <input type="hidden" id="chara7-server_id" value="4" />
            <input type="hidden" id="chara7-account_name" value="zthitemmoli" />
        </td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara7-chara_lr">
            <option value="1" selected>左</option>
            <option value="2">右</option>
        </select></td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara7-server_line">
            <option value="1">1线</option>
            <option value="2">2线</option>
            <option value="3">3线</option>
            <option value="4" selected>4线</option>
            <option value="5">5线</option>
            <option value="6">6线</option>
            <option value="7">7线</option>
            <option value="8">8线</option>
            <option value="9">9线</option>
            <option value="10">10线</option>
        </select></td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara7-autologin" checked />
                <label class="custom-control-label" for="chara7-autologin"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara7-skipupdate" checked />
                <label class="custom-control-label" for="chara7-skipupdate"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara7-autochangeserver" />
                <label class="custom-control-label" for="chara7-autochangeserver"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara7-scriptautorestart" checked />
                <label class="custom-control-label" for="chara7-scriptautorestart"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara7-injuryprotect" />
                <label class="custom-control-label" for="chara7-injuryprotect"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara7-soulprotect" />
                <label class="custom-control-label" for="chara7-soulprotect"></label>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-script_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara7-loadscript" value="【功能】说话防掉线.js" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    scriptFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-settings_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara7-loadsettings" value="[物理系]人低级气功弹带低级单补自己+宠普攻带吸血.json" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    settingsFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <button class="btn btn-info btn-sm" id="btn-chara7-save" onclick="onBtnSave(7);">保存</button>
            <button class="btn btn-success btn-sm" id="btn-chara7-startup" onclick="onBtnStartup(7);">启动</button>
            <script>
                chara_judge_running(7);
            </script>
        </td>
    </tr>
    <tr>
        <td>
            <input type="hidden" class="form-control form-control-sm chara-selected" id="chara8-selected" value="8" disabled />
            <div class="custom-control custom-checkbox">
                <input type="checkbox" class="custom-control-input chara-selected-checkbox" onchange="document.getElementById('chara8-selected').disabled = !this.checked;" id="chk-chara8-selected" />
                <label class="custom-control-label" for="chk-chara8-selected"></label>
            </div>
        </td>
        <td>
            <span id="chara8-chara_name">叶影の殇</span>
            <input type="hidden" id="chara8-gid_name" value="zth11111101" />
            <input type="hidden" id="chara8-server_id" value="4" />
            <input type="hidden" id="chara8-account_name" value="zth111111" />
        </td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara8-chara_lr">
            <option value="1" selected>左</option>
            <option value="2">右</option>
        </select></td>
        <td><select class="custom-control custom-select custom-select-sm" id="chara8-server_line">
            <option value="1">1线</option>
            <option value="2">2线</option>
            <option value="3">3线</option>
            <option value="4" selected>4线</option>
            <option value="5">5线</option>
            <option value="6">6线</option>
            <option value="7">7线</option>
            <option value="8">8线</option>
            <option value="9">9线</option>
            <option value="10">10线</option>
        </select></td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara8-autologin" checked />
                <label class="custom-control-label" for="chara8-autologin"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara8-skipupdate" checked />
                <label class="custom-control-label" for="chara8-skipupdate"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara8-autochangeserver" />
                <label class="custom-control-label" for="chara8-autochangeserver"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara8-scriptautorestart" checked />
                <label class="custom-control-label" for="chara8-scriptautorestart"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara8-injuryprotect" />
                <label class="custom-control-label" for="chara8-injuryprotect"></label>
            </div>
        </td>
        <td>
            <div class="custom-control custom-switch">
                <input type="checkbox" class="custom-control-input" id="chara8-soulprotect" />
                <label class="custom-control-label" for="chara8-soulprotect"></label>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-script_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara8-loadscript" value="【功能】说话防掉线.js" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    scriptFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <div class="dropdown dropdown-settings_files">
                <input type="text" class="form-control form-control-sm dropdown-toggle" data-toggle="dropdown" id="chara8-loadsettings" value="[物理系]人低级气功弹带低级单补自己+宠普攻带吸血.json" />
                <select class="form-control dropdown-menu" size="10" onclick="$(this).prev().val(this.value);">
                    <script>
                    settingsFiles.forEach( function(f) {
                        document.write('<option class="dropdown-item" value="' + f + '">' + f + '</option>');
                    } );
                    </script>
                </select>
            </div>
        </td>
        <td>
            <button class="btn btn-info btn-sm" id="btn-chara8-save" onclick="onBtnSave(8);">保存</button>
            <button class="btn btn-success btn-sm" id="btn-chara8-startup" onclick="onBtnStartup(8);">启动</button>
            <script>
                chara_judge_running(8);
            </script>
        </td>
    </tr>
    </tbody>
    </table>
    <script>
        function getChara(id) {
            var chara = {
                chara_id: id,
                chara_lr: $('#chara'+id+'-chara_lr').val(),
                gid_name: $('#chara'+id+'-gid_name').val(),
                server_id: $('#chara'+id+'-server_id').val(),
                account_name: $('#chara'+id+'-account_name').val(),
                server_line: $('#chara'+id+'-server_line').val(),
                autologin: $('#chara'+id+'-autologin')[0].checked+0,
                skipupdate: $('#chara'+id+'-skipupdate')[0].checked+0,
                autochangeserver: $('#chara'+id+'-autochangeserver')[0].checked+0,
                scriptautorestart: $('#chara'+id+'-scriptautorestart')[0].checked+0,
                injuryprotect: $('#chara'+id+'-injuryprotect')[0].checked+0,
                soulprotect: $('#chara'+id+'-soulprotect')[0].checked+0,
                loadscript: $('#chara'+id+'-loadscript').val(),
                loadsettings: $('#chara'+id+'-loadsettings').val(),
            };
            return chara;
        }
        function onBtnSave(id) {
            var elem = document.getElementById('btn-chara' + id + '-save');
            if ( elem.disabled ) return;
            elem.disabled = true;
            $.ajax( {
                url: 'action/quiklysave',
                data: getChara(id),
                dataType: 'json',
                success: function(data) {
                    console.log(data);
                    if ( !data.error ) {
                        elem.disabled = false;
                    }
                }
            } );
        }
        function onBtnStartup(id) {
            var elem = document.getElementById('btn-chara' + id + '-startup');
            if ( elem.disabled ) return;
            elem.disabled = true;
            $.ajax( {
                url: 'action/startupgame',
                data: getChara(id),
                dataType: 'json',
                success: function(data) {
                    $('#btn-chara'+id+'-startup').prop('disabled', true);
                    $('#btn-chara'+id+'-startup').text('运行中');
                    $('#btn-chara'+id+'-startup').removeClass('btn-success');
                    $('#btn-chara'+id+'-startup').addClass('btn-danger');
                }
            } );
        }
        function onChangeServer(serverId) {
            $.ajax( {
                url: 'action/changeserver',
                data: { server_id: serverId },
                dataType: 'json',
                success: function(data) {
                    if ( !data.error ) {
                        window.location.reload(true);
                    }
                }
            } );
        }
        function onMultiExec(opr) {
            var oCharaSelecteds = $('.chara-selected');
            var charaIds = [];
            for ( var i = 0; i < oCharaSelecteds.length; i++ ) {
                if ( !oCharaSelecteds[i].disabled ) {
                    //console.log(opr, oCharaSelecteds[i].value);
                    var id = oCharaSelecteds[i].value;
                    var oprFunc = eval(opr);
                    //console.log(id);
                    oprFunc(id);
                }
                
            }
            //console.log(o.length);
        }
    </script>
</div>
        </div>
    </div>

</body>

</html>
